/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aaron.platform.entity;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * user info class
 * @author chenzhuohua
 */
@Entity
@Table(name = "itsc_user_info")
@SequenceGenerator(name="itsc_user_generator", sequenceName="itsc_user_generator", allocationSize = 1)
public class ItscUserInfo extends BaseObject implements Serializable {

    private static final long serialVersionUID = 1L;

    public static final String PROPERTY_USER_NAME = "userName";
    
    public static final String PROPERTY_USER_CHINESE_NAME = "userChName";

    public static final String PROPERTY_USER_ROLEID = "roleInfo.roleId";

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator="itsc_user_generator")
    @Column(name = "user_id")
    private Integer userId;

    @Column(name = "user_name", updatable = false)
    private String userName;

    @Column(name = "user_pwd")
    private String userPwd;

    @Column(name = "user_telephone")
    private String userTelephone;
    
    @Column(name = "user_mail")
    private String userMail;

    @Column(name = "user_position")
    private String userPosition;
    
    @Column(name = "user_chinese_name")
    private String userChName;

    @OneToOne
    @JoinColumn(name = "role_id", referencedColumnName = "role_id")
    private ItscRoleInfo roleInfo;

    @ManyToOne
    @JoinColumn(name = "user_domain", referencedColumnName = "domain_id")
    private ItscDomainInfo domainInfo;

    /** default is true */
    @Column(name = "is_locked")
    private boolean locked;

    public ItscUserInfo() {
        super();
        this.locked = false;
    }

    public ItscUserInfo(Integer userId) {
        this.userId = userId;
        this.locked = false;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPwd() {
        return userPwd;
    }

    public void setUserPwd(String userPwd) {
        this.userPwd = userPwd;
    }

    public String getUserTelephone() {
        return userTelephone;
    }

    public void setUserTelephone(String userTelephone) {
        this.userTelephone = userTelephone;
    }

    public String getUserPosition() {
        return userPosition;
    }

    public void setUserPosition(String userPosition) {
        this.userPosition = userPosition;
    }

    public ItscRoleInfo getRoleInfo() {
        return roleInfo;
    }

    public void setRoleInfo(ItscRoleInfo roleInfo) {
        this.roleInfo = roleInfo;
    }

    public boolean isLocked() {
        return locked;
    }

    public void setLocked(boolean locked) {
        this.locked = locked;
    }

    public ItscDomainInfo getDomainInfo() {
        return domainInfo;
    }

    public void setDomainInfo(ItscDomainInfo domainInfo) {
        this.domainInfo = domainInfo;
    }

    public String getUserChName() {
        return userChName;
    }

    public void setUserChName(String userChName) {
        this.userChName = userChName;
    }

    public String getUserMail() {
        return userMail;
    }

    public void setUserMail(String userMail) {
        this.userMail = userMail;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (userId != null ? userId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ItscUserInfo)) {
            return false;
        }
        ItscUserInfo other = (ItscUserInfo) object;
        if ((this.userId == null && other.userId != null) || (this.userId != null && !this.userId.equals(other.userId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.aaron.test.entity.ItscUserInfo[userId=" + userId + "]";
    }
}
